﻿namespace UnityEditor
{
    using System;
    using System.Collections.Generic;
    using UnityEditorInternal;
    using UnityEngine;

    internal class TransitionPreview
    {
        private AvatarPreview m_AvatarPreview;
        private AnimatorController m_Controller;
        private List<Timeline.PivotSample> m_DstPivotList = new List<Timeline.PivotSample>();
        private UnityEditorInternal.State m_DstState;
        private StateMachine m_DummyStateMachine;
        private float m_ExitTime = 0.5f;
        private float m_LastEvalTime = -1f;
        private int m_LayerIndex;
        private AvatarBodyMask m_LayerMask;
        private float m_LeftStateTimeA;
        private float m_LeftStateTimeB = 1f;
        private float m_LeftStateWeightA;
        private float m_LeftStateWeightB = 1f;
        private int m_MotionSetIndex;
        private bool m_MustResample;
        private bool m_MustSampleMotions;
        private UnityEditorInternal.State m_RefSrcState;
        private Transition m_RefTransition;
        private TransitionInfo m_RefTransitionInfo = new TransitionInfo();
        private float m_RightStateTimeA;
        private float m_RightStateTimeB = 1f;
        private float m_RightStateWeightA;
        private float m_RightStateWeightB = 1f;
        private bool m_ShowBlendValue;
        private List<Timeline.PivotSample> m_SrcPivotList = new List<Timeline.PivotSample>();
        private UnityEditorInternal.State m_SrcState;
        private StateMachine m_StateMachine;
        private Timeline m_Timeline;
        private Transition m_Transition;

        private void ClearController()
        {
            if ((this.m_AvatarPreview != null) && (this.m_AvatarPreview.Animator != null))
            {
                AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, null);
            }
            UnityEngine.Object.DestroyImmediate(this.m_Controller);
            UnityEngine.Object.DestroyImmediate(this.m_StateMachine);
            UnityEngine.Object.DestroyImmediate(this.m_DummyStateMachine);
            UnityEngine.Object.DestroyImmediate(this.m_SrcState);
            UnityEngine.Object.DestroyImmediate(this.m_DstState);
            UnityEngine.Object.DestroyImmediate(this.m_Transition);
            this.m_StateMachine = null;
            this.m_DummyStateMachine = null;
            this.m_Controller = null;
            this.m_SrcState = null;
            this.m_DstState = null;
            this.m_Transition = null;
        }

        private void CopyStateForPreview(UnityEditorInternal.State src, ref UnityEditorInternal.State dst)
        {
            dst.SetName(src.GetName());
            dst.SetIKOnFeet(src.GetIKOnFeet());
            dst.SetMotion(0, src.GetMotion(this.m_MotionSetIndex));
            dst.SetSpeed(src.GetSpeed());
        }

        private void CopyTransitionForPreview(Transition src, ref Transition dst)
        {
            if (src != null)
            {
                dst.SetTransitionDuration(src.GetTransitionDuration());
                dst.SetTransitionOffset(src.GetTransitionOffset());
                this.SetExitTime(dst, this.GetExitTime(src));
            }
        }

        private void CreateController()
        {
            if (((this.m_Controller == null) && (this.m_AvatarPreview != null)) && ((this.m_AvatarPreview.Animator != null) && (this.m_RefTransition != null)))
            {
                this.m_StateMachine = new StateMachine();
                this.m_StateMachine.hideFlags = HideFlags.DontSave;
                UnityEditorInternal.State src = (this.m_RefTransition.GetSrcState() == null) ? this.m_RefSrcState : this.m_RefTransition.GetSrcState();
                this.m_SrcState = this.m_StateMachine.AddState(src.GetName());
                this.m_SrcState.hideFlags = HideFlags.DontSave;
                this.m_DstState = this.m_StateMachine.AddState(this.m_RefTransition.GetDstState().GetName());
                this.m_DstState.hideFlags = HideFlags.DontSave;
                this.CopyStateForPreview(src, ref this.m_SrcState);
                this.CopyStateForPreview(this.m_RefTransition.GetDstState(), ref this.m_DstState);
                this.m_Transition = this.m_StateMachine.AddTransition(this.m_SrcState, this.m_DstState);
                this.m_Transition.hideFlags = HideFlags.DontSave;
                this.CopyTransitionForPreview(this.m_RefTransition, ref this.m_Transition);
                this.m_LayerIndex = 0;
                this.m_Controller = new AnimatorController();
                this.m_Controller.hideFlags = HideFlags.DontSave;
                this.m_Controller.AddLayer("preview");
                bool flag = true;
                if (this.m_LayerMask != null)
                {
                    int bodyPartCount = this.m_LayerMask.GetBodyPartCount();
                    for (int i = 0; (i < bodyPartCount) && flag; i++)
                    {
                        if (!this.m_LayerMask.GetBodyPart(i))
                        {
                            flag = false;
                        }
                    }
                    if (!flag)
                    {
                        this.m_DummyStateMachine = new StateMachine();
                        this.m_Controller.SetLayerStateMachine(0, this.m_DummyStateMachine);
                        this.m_Controller.AddLayer("Additionnal");
                        this.m_LayerIndex++;
                        this.m_Controller.SetLayerHumanMask(this.m_LayerIndex, this.m_LayerMask);
                    }
                }
                this.DisableIKOnFeetIfNeeded();
                Motion motion = this.m_SrcState.GetMotion(this.m_MotionSetIndex);
                if ((motion != null) && (motion is BlendTree))
                {
                    BlendTree tree = motion as BlendTree;
                    for (int j = 0; j < tree.GetRecursiveBlendEventCount(); j++)
                    {
                        string recursiveBlendEvent = tree.GetRecursiveBlendEvent(j);
                        if (this.m_Controller.FindEvent(recursiveBlendEvent) == -1)
                        {
                            this.m_Controller.AddEvent(recursiveBlendEvent, AnimatorControllerEventType.Float);
                        }
                    }
                }
                Motion motion2 = this.m_DstState.GetMotion(this.m_MotionSetIndex);
                if ((motion2 != null) && (motion2 is BlendTree))
                {
                    BlendTree tree2 = motion2 as BlendTree;
                    for (int k = 0; k < tree2.GetRecursiveBlendEventCount(); k++)
                    {
                        string name = tree2.GetRecursiveBlendEvent(k);
                        if (this.m_Controller.FindEvent(name) == -1)
                        {
                            this.m_Controller.AddEvent(name, AnimatorControllerEventType.Float);
                        }
                    }
                }
                this.m_Controller.SetLayerStateMachine(this.m_LayerIndex, this.m_StateMachine);
                AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
            }
        }

        private void DisableIKOnFeetIfNeeded()
        {
            bool flag = false;
            if ((this.m_SrcState.GetMotion(0) == null) || (this.m_DstState.GetMotion(0) == null))
            {
                flag = true;
            }
            if (this.m_LayerIndex > 0)
            {
                flag = !this.m_LayerMask.hasFeetIK;
            }
            if (flag)
            {
                this.m_SrcState.SetIKOnFeet(false);
                this.m_DstState.SetIKOnFeet(false);
            }
        }

        private void DoTimeline()
        {
            float num = (this.m_LeftStateTimeB - this.m_LeftStateTimeA) / (this.m_LeftStateWeightB - this.m_LeftStateWeightA);
            float num2 = (this.m_RightStateTimeB - this.m_RightStateTimeA) / (this.m_RightStateWeightB - this.m_RightStateWeightA);
            float num3 = this.m_Transition.GetTransitionDuration() * num;
            this.m_Timeline.SrcStartTime = 0f;
            this.m_Timeline.SrcStopTime = num;
            this.m_Timeline.SrcName = this.m_SrcState.GetName();
            this.m_Timeline.HasExitTime = this.HasExitTime(this.m_RefTransition);
            this.m_Timeline.srcLoop = (this.m_SrcState.GetMotion(0) != null) && this.m_SrcState.GetMotion(0).isLooping;
            this.m_Timeline.dstLoop = (this.m_DstState.GetMotion(0) != null) && this.m_DstState.GetMotion(0).isLooping;
            this.m_Timeline.TransitionStartTime = this.GetExitTime(this.m_RefTransition) * num;
            this.m_Timeline.TransitionStopTime = this.m_Timeline.TransitionStartTime + num3;
            this.m_Timeline.Time = this.m_AvatarPreview.timeControl.currentTime;
            this.m_Timeline.DstStartTime = this.m_Timeline.TransitionStartTime - (this.m_RefTransition.GetTransitionOffset() * num2);
            this.m_Timeline.DstStopTime = this.m_Timeline.DstStartTime + num2;
            if (this.m_Timeline.TransitionStopTime == float.PositiveInfinity)
            {
                this.m_Timeline.TransitionStopTime = Mathf.Min(this.m_Timeline.DstStopTime, this.m_Timeline.SrcStopTime);
            }
            this.m_Timeline.DstName = this.m_DstState.GetName();
            this.m_Timeline.SrcPivotList = this.m_SrcPivotList;
            this.m_Timeline.DstPivotList = this.m_DstPivotList;
            Rect timeRect = EditorGUILayout.GetControlRect(false, 150f, EditorStyles.label, new GUILayoutOption[0]);
            EditorGUI.BeginChangeCheck();
            this.m_Timeline.DoTimeline(timeRect);
            if (EditorGUI.EndChangeCheck())
            {
                float b = this.m_Timeline.TransitionStartTime / this.m_Timeline.SrcDuration;
                float num5 = this.m_Timeline.TransitionDuration / this.m_Timeline.SrcDuration;
                float num6 = (this.m_Timeline.TransitionStartTime - this.m_Timeline.DstStartTime) / this.m_Timeline.DstDuration;
                if ((!Mathf.Approximately(this.GetExitTime(this.m_RefTransition), b) || !Mathf.Approximately(this.m_RefTransition.GetTransitionDuration(), num5)) || !Mathf.Approximately(this.m_RefTransition.GetTransitionOffset(), num6))
                {
                    Undo.RegisterUndo(this.m_RefTransition, "Edit Transition");
                    this.SetExitTime(this.m_RefTransition, this.m_Timeline.TransitionStartTime / this.m_Timeline.SrcDuration);
                    this.m_RefTransition.SetTransitionDuration(this.m_Timeline.TransitionDuration / this.m_Timeline.SrcDuration);
                    this.m_RefTransition.SetTransitionOffset((this.m_Timeline.TransitionStartTime - this.m_Timeline.DstStartTime) / this.m_Timeline.DstDuration);
                }
                this.m_AvatarPreview.timeControl.currentTime = this.m_Timeline.Time;
                this.m_AvatarPreview.timeControl.startTime = this.m_Timeline.StartTime;
                this.m_AvatarPreview.timeControl.stopTime = this.m_Timeline.StopTime;
            }
        }

        public void DoTransitionPreview()
        {
            if (this.m_Controller != null)
            {
                this.m_AvatarPreview.timeControl.Update();
                this.DoTimeline();
                if (this.m_Timeline.MarkerStartTime != this.m_AvatarPreview.timeControl.startTime)
                {
                    this.m_AvatarPreview.timeControl.startTime = this.m_Timeline.MarkerStartTime;
                }
                if (this.m_Timeline.MarkerStopTime != this.m_AvatarPreview.timeControl.stopTime)
                {
                    this.m_AvatarPreview.timeControl.stopTime = this.m_Timeline.MarkerStopTime;
                }
                this.m_AvatarPreview.timeControl.currentTime = this.m_Timeline.Time;
                int eventCount = this.m_Controller.GetEventCount();
                EditorGUIUtility.LookLikeControls();
                if (eventCount > 0)
                {
                    this.m_ShowBlendValue = EditorGUILayout.Foldout(this.m_ShowBlendValue, "BlendTree Parameters");
                    if (this.m_ShowBlendValue)
                    {
                        for (int i = 0; i < eventCount; i++)
                        {
                            string eventName = this.m_Controller.GetEventName(i);
                            float @float = this.m_AvatarPreview.Animator.GetFloat(eventName);
                            float num4 = EditorGUILayout.Slider(eventName, @float, this.m_Controller.GetEventMin(i), this.m_Controller.GetEventMax(i), new GUILayoutOption[0]);
                            if (num4 != @float)
                            {
                                this.m_AvatarPreview.Animator.SetFloat(eventName, num4);
                                this.mustResample = true;
                                this.m_MustSampleMotions = true;
                            }
                        }
                    }
                }
            }
        }

        private int FindEventInfo(List<EventInfo> eventInfoList, string name)
        {
            int num = -1;
            for (int i = 0; (i < eventInfoList.Count) && (num == -1); i++)
            {
                if (eventInfoList[i].m_Name == name)
                {
                    num = i;
                }
            }
            return num;
        }

        private float GetExitTime(Transition t)
        {
            for (int i = 0; i < t.GetConditionCount(); i++)
            {
                if (t.GetConditionMode(i) == TransitionConditionMode.ExitTime)
                {
                    return t.GetExitTime(i);
                }
            }
            return this.m_ExitTime;
        }

        private bool HasExitTime(Transition t)
        {
            for (int i = 0; i < t.GetConditionCount(); i++)
            {
                if (t.GetConditionMode(i) == TransitionConditionMode.ExitTime)
                {
                    return true;
                }
            }
            return false;
        }

        public bool HasPreviewGUI()
        {
            return true;
        }

        private void Init(Animator scenePreviewObject, Motion motion)
        {
            if (this.m_AvatarPreview == null)
            {
                this.m_AvatarPreview = new AvatarPreview(scenePreviewObject, motion);
                this.m_AvatarPreview.OnAvatarChangeFunc = new AvatarPreview.OnAvatarChange(this.OnPreviewAvatarChanged);
                this.m_AvatarPreview.ShowIKOnFeetButton = false;
            }
            if (this.m_Timeline == null)
            {
                this.m_Timeline = new Timeline();
                this.m_MustSampleMotions = true;
            }
            this.CreateController();
        }

        private bool MustResample(TransitionInfo info)
        {
            return (this.mustResample || !info.IsEqual(this.m_RefTransitionInfo));
        }

        public void OnDestroy()
        {
            this.ClearController();
            if (this.m_Timeline != null)
            {
                this.m_Timeline = null;
            }
            if (this.m_AvatarPreview != null)
            {
                this.m_AvatarPreview.OnDestroy();
                this.m_AvatarPreview = null;
            }
        }

        public void OnDisable()
        {
            this.ClearController();
        }

        public void OnInteractivePreviewGUI(Rect r, GUIStyle background)
        {
            if ((this.m_AvatarPreview != null) && (this.m_Controller != null))
            {
                if (this.m_LastEvalTime != this.m_AvatarPreview.timeControl.currentTime)
                {
                    this.m_AvatarPreview.Animator.PlaybackRecordedFrame(this.m_AvatarPreview.timeControl.currentTime);
                    this.m_LastEvalTime = this.m_AvatarPreview.timeControl.currentTime;
                }
                this.m_AvatarPreview.DoAvatarPreview(r, background);
            }
        }

        private void OnPreviewAvatarChanged()
        {
            this.m_RefTransitionInfo = new TransitionInfo();
            this.ClearController();
            this.CreateController();
        }

        public void OnPreviewSettings()
        {
            if (this.m_AvatarPreview != null)
            {
                this.m_AvatarPreview.DoPreviewSettings();
            }
        }

        private void ResampleTransition(Transition transition, AvatarBodyMask layerMask, TransitionInfo info, Animator previewObject)
        {
            List<EventInfo> eventInfoList = new List<EventInfo>();
            if (this.m_Controller != null)
            {
                int eventCount = this.m_Controller.GetEventCount();
                for (int i = 0; i < eventCount; i++)
                {
                    EventInfo info2;
                    info2 = new EventInfo {
                        m_Name = this.m_Controller.GetEventName(i),
                        m_Value = this.m_AvatarPreview.Animator.GetFloat(info2.m_Name)
                    };
                    eventInfoList.Add(info2);
                }
            }
            this.m_MustResample = false;
            bool flag = this.m_RefTransition != transition;
            this.m_RefTransition = transition;
            this.m_RefTransitionInfo = info;
            this.m_LayerMask = layerMask;
            if (this.m_AvatarPreview != null)
            {
                this.m_AvatarPreview.OnDestroy();
                this.m_AvatarPreview = null;
            }
            this.ClearController();
            Motion motion = (transition.GetSrcState() == null) ? this.m_RefSrcState.GetMotion(this.m_MotionSetIndex) : transition.GetSrcState().GetMotion(this.m_MotionSetIndex);
            this.Init(previewObject, (motion == null) ? transition.GetDstState().GetMotion(this.m_MotionSetIndex) : motion);
            if (this.m_Controller != null)
            {
                this.m_StateMachine.SetDefaultState(this.m_DstState);
                this.m_Transition.SetMute(true);
                AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                this.WriteParametersInController(eventInfoList);
                this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
                this.m_AvatarPreview.Animator.Update(1E-05f);
                float length = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
                this.m_StateMachine.SetDefaultState(this.m_SrcState);
                this.m_Transition.SetMute(false);
                AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                this.WriteParametersInController(eventInfoList);
                this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
                this.m_AvatarPreview.Animator.Update(1E-05f);
                float num4 = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex).length;
                if (this.m_LayerIndex > 0)
                {
                    this.m_AvatarPreview.Animator.stabilizeFeet = false;
                }
                float num5 = num4 + length;
                float num7 = 0f;
                bool flag2 = false;
                bool flag3 = false;
                bool flag4 = false;
                this.m_AvatarPreview.Animator.StartRecording();
                this.m_LeftStateWeightA = 0f;
                this.m_LeftStateTimeA = 0f;
                this.m_AvatarPreview.Animator.Update(0f);
                while (!flag4)
                {
                    this.m_AvatarPreview.Animator.Update(0.03333334f);
                    AnimatorStateInfo currentAnimatorStateInfo = this.m_AvatarPreview.Animator.GetCurrentAnimatorStateInfo(this.m_LayerIndex);
                    num7 += 0.03333334f;
                    if (!flag2)
                    {
                        this.m_LeftStateWeightA = currentAnimatorStateInfo.normalizedTime;
                        this.m_LeftStateTimeA = num7;
                        flag2 = true;
                    }
                    if (!flag3 && currentAnimatorStateInfo.IsName(this.m_DstState.GetUniqueName()))
                    {
                        this.m_RightStateWeightA = currentAnimatorStateInfo.normalizedTime;
                        this.m_RightStateTimeA = num7;
                        flag3 = true;
                    }
                    if (!flag3)
                    {
                        this.m_LeftStateWeightB = currentAnimatorStateInfo.normalizedTime;
                        this.m_LeftStateTimeB = num7;
                    }
                    if (flag3)
                    {
                        this.m_RightStateWeightB = currentAnimatorStateInfo.normalizedTime;
                        this.m_RightStateTimeB = num7;
                    }
                    if (flag3 && (num7 >= num5))
                    {
                        flag4 = true;
                    }
                }
                float num8 = num7;
                this.m_AvatarPreview.Animator.StopRecording();
                float num9 = (this.m_LeftStateTimeB - this.m_LeftStateTimeA) / (this.m_LeftStateWeightB - this.m_LeftStateWeightA);
                float num10 = (this.m_RightStateTimeB - this.m_RightStateTimeA) / (this.m_RightStateWeightB - this.m_RightStateWeightA);
                if (this.m_MustSampleMotions)
                {
                    this.m_MustSampleMotions = false;
                    this.m_SrcPivotList.Clear();
                    this.m_DstPivotList.Clear();
                    this.m_StateMachine.SetDefaultState(this.m_DstState);
                    this.m_Transition.SetMute(true);
                    AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                    this.WriteParametersInController(eventInfoList);
                    this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
                    this.m_AvatarPreview.Animator.Update(1E-07f);
                    num7 = 0f;
                    while (num7 <= num10)
                    {
                        this.m_AvatarPreview.Animator.Update(0.06666667f);
                        num7 += 0.06666667f;
                        Timeline.PivotSample item = new Timeline.PivotSample {
                            m_Time = num7,
                            m_Weight = this.m_AvatarPreview.Animator.pivotWeight
                        };
                        this.m_DstPivotList.Add(item);
                    }
                    this.m_StateMachine.SetDefaultState(this.m_SrcState);
                    this.m_Transition.SetMute(true);
                    AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                    this.WriteParametersInController(eventInfoList);
                    this.m_AvatarPreview.Animator.SetLayerWeight(this.m_LayerIndex, 1f);
                    this.m_AvatarPreview.Animator.Update(1E-07f);
                    num7 = 0f;
                    while (num7 <= num9)
                    {
                        this.m_AvatarPreview.Animator.Update(0.06666667f);
                        num7 += 0.06666667f;
                        Timeline.PivotSample sample2 = new Timeline.PivotSample {
                            m_Time = num7,
                            m_Weight = this.m_AvatarPreview.Animator.pivotWeight
                        };
                        this.m_SrcPivotList.Add(sample2);
                    }
                    this.m_Transition.SetMute(false);
                    AnimatorController.SetAnimatorController(this.m_AvatarPreview.Animator, this.m_Controller);
                    this.WriteParametersInController(eventInfoList);
                    this.m_AvatarPreview.Animator.Update(1E-07f);
                }
                if (flag)
                {
                    float num11;
                    this.m_AvatarPreview.timeControl.currentTime = num11 = this.m_AvatarPreview.timeControl.startTime = 0f;
                    this.m_Timeline.StartTime = num11;
                    this.m_Timeline.Time = num11;
                    this.m_Timeline.StopTime = this.m_AvatarPreview.timeControl.stopTime = num8;
                    this.m_Timeline.ResetMarkersAndRange();
                }
            }
        }

        public void SetAnyStateTransition(Transition transition, UnityEditorInternal.State sourceState, AvatarBodyMask layerMask, int motionSetIndex, Animator previewObject)
        {
            TransitionInfo info = new TransitionInfo();
            info.Set(transition, sourceState);
            this.m_MotionSetIndex = motionSetIndex;
            if (this.MustResample(info))
            {
                this.m_RefSrcState = sourceState;
                this.ResampleTransition(transition, layerMask, info, previewObject);
            }
        }

        private void SetExitTime(Transition t, float time)
        {
            for (int i = 0; i < t.GetConditionCount(); i++)
            {
                if (t.GetConditionMode(i) == TransitionConditionMode.ExitTime)
                {
                    t.SetExitTime(i, time);
                    break;
                }
            }
            this.m_ExitTime = time;
        }

        public void SetTransition(Transition transition, AvatarBodyMask layerMask, int motionSetIndex, Animator previewObject)
        {
            TransitionInfo info = new TransitionInfo();
            info.Set(transition, null);
            this.m_MotionSetIndex = motionSetIndex;
            if (this.MustResample(info))
            {
                this.ResampleTransition(transition, layerMask, info, previewObject);
            }
        }

        private void WriteParametersInController(List<EventInfo> eventInfoList)
        {
            if (this.m_Controller != null)
            {
                int eventCount = this.m_Controller.GetEventCount();
                for (int i = 0; i < eventCount; i++)
                {
                    string eventName = this.m_Controller.GetEventName(i);
                    int num3 = this.FindEventInfo(eventInfoList, eventName);
                    if (num3 != -1)
                    {
                        this.m_AvatarPreview.Animator.SetFloat(eventName, eventInfoList[num3].m_Value);
                    }
                }
            }
        }

        public bool mustResample
        {
            get
            {
                return this.m_MustResample;
            }
            set
            {
                this.m_MustResample = value;
            }
        }

        private class EventInfo
        {
            public string m_Name;
            public float m_Value;
        }

        private class TransitionInfo
        {
            private UnityEditorInternal.State m_DstState;
            private float m_ExitTime;
            private UnityEditorInternal.State m_SrcState;
            private float m_TransitionDuration;
            private float m_TransitionOffset;

            public TransitionInfo()
            {
                this.Init();
            }

            private void Init()
            {
                this.m_SrcState = null;
                this.m_DstState = null;
                this.m_TransitionDuration = 0f;
                this.m_TransitionOffset = 0f;
                this.m_ExitTime = 0.5f;
            }

            public bool IsEqual(TransitionPreview.TransitionInfo info)
            {
                return ((((this.m_SrcState == info.m_SrcState) && (this.m_DstState == info.m_DstState)) && ((this.m_TransitionDuration == info.m_TransitionDuration) && (this.m_TransitionOffset == info.m_TransitionOffset))) && (this.m_ExitTime == info.m_ExitTime));
            }

            public void Set(Transition transition, UnityEditorInternal.State srcState)
            {
                if (transition != null)
                {
                    if (srcState != null)
                    {
                        this.m_SrcState = srcState;
                    }
                    else
                    {
                        this.m_SrcState = transition.GetSrcState();
                    }
                    this.m_DstState = transition.GetDstState();
                    this.m_TransitionDuration = transition.GetTransitionDuration();
                    this.m_TransitionOffset = transition.GetTransitionOffset();
                    this.m_ExitTime = 0.5f;
                    for (int i = 0; i < transition.GetConditionCount(); i++)
                    {
                        if (transition.GetConditionMode(i) == TransitionConditionMode.ExitTime)
                        {
                            this.m_ExitTime = transition.GetExitTime(i);
                            break;
                        }
                    }
                }
                else
                {
                    this.Init();
                }
            }
        }
    }
}

